﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="web._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="UTF-8">
  <title>Summernote</title>
  <link type="text/css" href="bootstrap/3.3.5/css/bootstrap.css"rel="stylesheet"/>
  <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script> 
  <script type="text/javascript" src="bootstrap/3.3.5/js/bootstrap.js"></script> 
  <link type="text/css" href="summernote/summernote.css"rel="stylesheet"/>
  <script type="text/javascript" src="summernote/summernote.js"></script>
  <script type="text/javascript" src="WordPaster/js/json2.min.js" charset="utf-8"></script>
  <script type="text/javascript" src="WordPaster/js/layer-3.1.1/layer.js" charset="utf-8"></script>
  <script type="text/javascript" src="WordPaster/js/w.layer.js" charset="utf-8"></script>
  <script type="text/javascript" src="zyCapture/z.layer.js" charset="utf-8"></script>
  <script type="text/javascript" src="zyOffice/js/o.layer.js" charset="utf-8"></script>
</head>
<body>  
  <div id="summernote"><p>Hello Summernote</p></div>
    <script type="text/javascript">
        $(document).ready(function () {
            var pos = window.location.href.lastIndexOf("/");
            var api = [
                window.location.href.substr(0, pos + 1),
                "upload.aspx"
            ].join("");
            WordPaster.getInstance({
                //上传接口：http://www.ncmem.com/doc/view.aspx?id=d88b60a2b0204af1ba62fa66288203ed
                PostUrl: api,
                //为图片地址增加域名：http://www.ncmem.com/doc/view.aspx?id=704cd302ebd346b486adf39cf4553936
                ImageUrl: "",
                //设置文件字段名称：http://www.ncmem.com/doc/view.aspx?id=c3ad06c2ae31454cb418ceb2b8da7c45
                FileFieldName: "file",
                //提取图片地址：http://www.ncmem.com/doc/view.aspx?id=07e3f323d22d4571ad213441ab8530d1
                ImageMatch: '',
                Cookie: 'ASP.NET_SessionId=<%=Session.SessionID%>',
                //自定义参数
                Fields: {},
                event:{
				    dataReady:function(e){
					    //e.word,
					    //e.imgs:tag1,tag2,tag3
					    console.log(e.imgs)
				    }
			    }
            });//加载控件

            //zyCapture
            zyCapture.getInstance({
                config: {
                    PostUrl: api,
				    FileFieldName: "file",
                    Fields: { uname: "test" }
                }
            });

            //zyoffice，
            //使用前请在服务端部署zyoffice，
            //http://www.ncmem.com/doc/view.aspx?id=82170058de824b5c86e2e666e5be319c
            zyOffice.getInstance({
                word:"http://localhost:13710/zyoffice/word/convert",
                wordExport:"http://localhost:13710/zyoffice/word/export",
                pdf:"http://localhost:13710/zyoffice/pdf/upload"
            });

            $.extend(true, $.summernote.lang, {
                'en-US': {/* US English(Default Language) */
                    wordpaster: {tooltip:"Word一键粘贴"},
                    importwordtoimg: {tooltip:"Word转图片"},
                    netpaster: {tooltip:"自动上传网络图片"},
                    wordimport: {tooltip:"导入Word文档"},
					excelimport: {tooltip:"导入Excel文档"},
                    pptimport: {tooltip:"导入PPT文档"},                    
                    pdfimport: {tooltip:"导入PDF文档"},
                    zycapture: {tooltip:"截屏（zyCapture）"},
                    importword: {tooltip:"导入Word文档（docx）"},
                    exportword: {tooltip:"导出Word文档（docx）"},
                    importpdf: {tooltip:"导入PDF文档"}
                }
            });

            $.extend($.summernote.options, {
                wordpaster: {icon: '<img src="WordPaster/css/word.png"/>'},
                importwordtoimg: {icon: '<img src="WordPaster/css/word1.png"/>'},
                netpaster: {icon: '<img src="WordPaster/css/net.png"/>'},
                wordimport: {icon: '<img src="WordPaster/css/word2.png"/>'},
				excelimport: {icon: '<img src="WordPaster/css/xls.png"/>'},
                pptimport: {icon: '<img src="WordPaster/css/ppt.png"/>'},                
                pdfimport: {icon: '<img src="WordPaster/css/pdf.png"/>'},
                zycapture: {icon: '<img src="zyCapture/z.png"/>'},
                importword: {icon: '<img src="zyOffice/css/w.png"/>'},
                exportword: {icon: '<img src="zyOffice/css/exword.png"/>'},
                importpdf: {icon: '<img src="zyOffice/css/pdf.png"/>'}
            });

            $.extend($.summernote.plugins, {
                'wordpaster': function (context) {
                    var self = this,
                        ui = $.summernote.ui,
                        options = context.options,
                        lang = options.langInfo;

                    context.memo('button.wordpaster', function () {
                        var button = ui.button({
                            tooltip: lang.wordpaster.tooltip,
                            contents:options.wordpaster.icon,
                            click: function (e) {
                                WordPaster.getInstance().SetEditor("#summernote").PasteManual();
                            }
                        });
                        return button.render();
                    });
                },
                'importwordtoimg': function (context) {
                    var self = this,
                        ui = $.summernote.ui,
                        options = context.options,
                        lang = options.langInfo;

                    context.memo('button.importwordtoimg', function () {
                        var button = ui.button({
                            tooltip: lang.importwordtoimg.tooltip,
                            contents:options.importwordtoimg.icon,
                            click: function (e) {
                                WordPaster.getInstance().SetEditor("#summernote").importWordToImg();
                            }
                        });
                        return button.render();
                    });
                },
                'netpaster': function (context) {
                    var self = this,
                        ui = $.summernote.ui,
                        options = context.options,
                        lang = options.langInfo;

                    context.memo('button.netpaster', function () {
                        var button = ui.button({
                            tooltip: lang.netpaster.tooltip,
                            contents:options.netpaster.icon,
                            click: function (e) {
                                WordPaster.getInstance().SetEditor("#summernote").UploadNetImg();
                            }
                        });
                        return button.render();
                    });
                },
                'wordimport': function (context) {
                    var self = this,
                        ui = $.summernote.ui,
                        options = context.options,
                        lang = options.langInfo;

                    context.memo('button.wordimport', function () {
                        var button = ui.button({
                            tooltip: lang.wordimport.tooltip,
                            contents:options.wordimport.icon,
                            click: function (e) {
                                WordPaster.getInstance().SetEditor("#summernote").importWord();
                            }
                        });
                        return button.render();
                    });
                },
                'excelimport': function (context) {
                    var self = this,
                        ui = $.summernote.ui,
                        options = context.options,
                        lang = options.langInfo;

                    context.memo('button.excelimport', function () {
                        var button = ui.button({
                            tooltip: lang.excelimport.tooltip,
                            contents:options.excelimport.icon,
                            click: function (e) {
                                WordPaster.getInstance().SetEditor("#summernote").importExcel();
                            }
                        });
                        return button.render();
                    });
                },
                'pptimport': function (context) {
                    var self = this,
                        ui = $.summernote.ui,
                        options = context.options,
                        lang = options.langInfo;

                    context.memo('button.pptimport', function () {
                        var button = ui.button({
                            tooltip: lang.pptimport.tooltip,
                            contents:options.pptimport.icon,
                            click: function (e) {
                                WordPaster.getInstance().SetEditor("#summernote").importPPT();
                            }
                        });
                        return button.render();
                    });
                },
                'pdfimport': function (context) {
                    var self = this,
                        ui = $.summernote.ui,
                        options = context.options,
                        lang = options.langInfo;

                    context.memo('button.pdfimport', function () {
                        var button = ui.button({
                            tooltip: lang.pdfimport.tooltip,
                            contents:options.pdfimport.icon,
                            click: function (e) {
                                WordPaster.getInstance().SetEditor("#summernote").ImportPDF();
                            }
                        });
                        return button.render();
                    });
                },
                'zycapture': function (context) {
                    var self = this,
                        ui = $.summernote.ui,
                        options = context.options,
                        lang = options.langInfo;

                    context.memo('button.zycapture', function () {
                        var button = ui.button({
                            tooltip: lang.zycapture.tooltip,
                            contents:options.zycapture.icon,
                            click: function (e) {                                
                                zyCapture.setEditor("#summernote").Capture2();
                            }
                        });
                        return button.render();
                    });
                },
                'importword': function (context) {
                    var self = this,
                        ui = $.summernote.ui,
                        options = context.options,
                        lang = options.langInfo;

                    context.memo('button.importword', function () {
                        var button = ui.button({
                            tooltip: lang.importword.tooltip,
                            contents:options.importword.icon,
                            click: function (e) {                                                                
                                zyOffice.SetEditor("#summernote").api.openDoc();
                            }
                        });
                        return button.render();
                    });
                },
                'exportword': function (context) {
                    var self = this,
                        ui = $.summernote.ui,
                        options = context.options,
                        lang = options.langInfo;

                    context.memo('button.exportword', function () {
                        var button = ui.button({
                            tooltip: lang.exportword.tooltip,
                            contents:options.exportword.icon,
                            click: function (e) {                                                                                                
                                zyOffice.SetEditor("#summernote").api.exportWord();
                            }
                        });
                        return button.render();
                    });
                },
                'importpdf': function (context) {
                    var self = this,
                        ui = $.summernote.ui,
                        options = context.options,
                        lang = options.langInfo;

                    context.memo('button.importpdf', function () {
                        var button = ui.button({
                            tooltip: lang.importpdf.tooltip,
                            contents:options.importpdf.icon,
                            click: function (e) {                                                                                                                                
                                zyOffice.SetEditor("#summernote").api.openPdf();
                            }
                        });
                        return button.render();
                    });
                }
            });

            $('#summernote').summernote({
                toolbar: [
                    ['style', ['style']],
                    ['font', ['bold', 'underline', 'clear']],
                    ['fontname', ['fontname']],
                    ['color', ['color']],
                    ['para', ['ul', 'ol', 'paragraph']],
                    ['table', ['table']],
                    ['insert', ['link', 'picture', 'video']],
                    ['view', ['fullscreen', 'codeview', 'help','zycapture','wordpaster','importwordtoimg','netpaster','wordimport','excelimport','pptimport','pdfimport','importword','exportword','importpdf']],
                ]
            });
        });
    </script>
</body>
</html>
